#include <bits/stdc++.h>
#define fi first
#define se second
using ll = long long;
using namespace std;
void solve()
{
    map<ll, ll> mp;
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n + 1);
    ll ans = 0;
    for (ll i = 1; i <= n; i++)
    {
        cin >> a[i];
        if (i != x)
        {
            mp[a[i]]++;
            ans = max(ans, a[i]);
        }
    }
    cout << mp[ans];
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
    int T = 1;
    // cin>>T;
    while (T--)
    {
        solve();
    }
    return 0;
}